The present invention relates generally to computer systems and software programs, and more specifically to locks in software loops.
In some software programs, it is necessary to acquire a lock on an object in order to perform certain operations that are dependent on the object being in a locked state. Subsequent to performing the operation(s), the lock is released. In some cases, such a lock is found within a software loop, and so lock acquisition on, and release of, an object may occur repeatedly, with each iteration of the loop. While placing the lock in the loop may be convenient and safe, repeated and unnecessary lock acquisition and release may significantly degrade the performance of the software program.
An improved method and system for acquiring and releasing locks within a software program is therefore desirable.